﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DDD.Core;
using DDD.Helper;

namespace DDDTest.Core {
    [TestClass]
    public class TestHelperMath {
        [TestMethod]
        public void Test_ClampToByte () {
            Assert.AreEqual (-128, MyMath.ClampToSByte (-129));
            Assert.AreEqual (-32768, MyMath.ClampToShort (-32769));
            Assert.AreEqual (-2147483648, MyMath.ClampToInt (-2147483649));
            Assert.AreEqual (127, MyMath.ClampToSByte (128));
            Assert.AreEqual (32767, MyMath.ClampToShort (32768));
            Assert.AreEqual (2147483647, MyMath.ClampToInt (2147483648));

            Assert.AreEqual (0u, MyMath.ClampToByte (-1));
            Assert.AreEqual (0u, MyMath.ClampToUShort (-1));
            Assert.AreEqual (0u, MyMath.ClampToUInt (-1));
            Assert.AreEqual (255, MyMath.ClampToByte (256));
            Assert.AreEqual (65535, MyMath.ClampToUShort (65536));
            Assert.AreEqual (4294967295, MyMath.ClampToUInt (4294967296));
        }
    }
}
